Week 3 Homework

Write a python program to save a well formatted fasta file


In [1]:
sequence_description = "gb|AF333238|A/Brevig Mission/1/1918(H1N1)|Segment:8|Subtype:H1N1|Host:Human"
sequence = "ATGGATTCCAACACTGTGTCAAGCTTTCAGGTAGACTGCTTTCTTTGGCATGTCCGCAAACGGTTTGCAGACCAAGAACTGGGTGATGCCCCATTCCTTGATCGGCTTCGCCGAGATCAGAAGTCCCTAAGAGGAAGAGGCAGCACTCTTGGTCTGGACATCGAGACAGCCACCCGTGCTGGAAAGCAGATAGTGGAGCGGATTCTGAAGGAAGAATCCGATGAGGCACTTAAAATGACCATTGCCTCTGTACCTGCTTCGCGCTACCTAACTGACATGACTCTTGAGGAGATGTCAAGGGACTGGTTCATGCTCATGCCCAAGCAGAAAGTGGCAGGCTCTCTTTGTATCAGAATGGACCAGGCGATCATGGATAAGAACATCATACTGAAAGCGAACTTCAGTGTGATTTTCGACCGGCTGGAGACTCTAATACTACTAAGGGCTTTCACCGAAGAGGGAGCAATTGTTGGCGAAATTTCACCATTGCCTTCTCTTCCAGGACATACTGATGAGGATGTCAAAAATGCAGTTGGGGTCCTCATCGGAGGACTTGAATGGAATGATAACACAGTTCGAGTCTCTGAAACTCTACAGAGATTCGCTTGGAGAAGCAGTAATGAGAATGGGAGACCTCCACTCCCTCCAAAACAGAAACGGAAAATGGCGAGAACAATTAAGTCAGAAGTTTGAAGAAATAAGATGGTTGATTGAAGAAGTGAGACATAGACTGAAGATAACAGAGAATAGTTTTGAGCAAATAACATTTATGCAAGCCTTACAACTATTGCTTGAAGTGGAGCAAGAGATAAGAACTTTCTCGTTTCAGCTTATTTAA"

Pseudocode

Pseudocode is the term used to describe a draft outline of a program written in plain English (or whatever language you write it in :-) ). We use pseudocode to discuss the functionality of the program as well as key elements in the program. Starting a program by using pseudocode can help to get your logic down quickly without having to be concerned with hte exact details or syntax of the programming language.

Create a FASTA file of the data above and make the sequence lowercase.

Requirements:

  • A ">" sign at the beginning of the description line
  • Make all the sequence lowercase
  • Parse the accession number (AF333238) from teh description
  • Used the parsed accession to save the file name as 'AF333238.fasta"

Want to know more about FASTA files? Check this webpage out.

Pseudocode:

  • Read the description
  • Parse out the accession number form the description (Hint: use the sequence_description.split() function; user parsed_description[1] )
  • Create a new file with the filename "AF333238.fasta" ## Do not hard code the file name
  • Save the description but add a ">" sign at the beginning of the description line
  • Make the sequence lowercase
  • Write the sequence data

NOTE: Please get into the good habit of commenting your code and describing what you are going to do or are doing. There must be at least one comment in your code.

NOTE: Next week we will see how to break the sequence into 80-mers


In [ ]:
# Write your code here (if you wish)

If you would like to create a file with your source doe paste it in the cell below and run. Please remember to add your name to the file.


In [ ]:
%%writefile FASTA_formatter.py

#Paste Code here

In [ ]:
%%python3 FASTA_formatter.py